<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$this->model('member')->checklogin();
$this->model('model')->checkbang();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','mobile','avatar','nickname'));;
	if(!$member){
		exi('找不到会员信息！','error');
	}
	$member['id']=$_SESSION['uid'];
	$return['member']=$member;
	$return['item']=pdo_get('jy_jianghu_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['bangpai']=pdo_get('jy_jianghu_bangpai',array('mid'=>$_SESSION['uid']));
	$this->model('model')->getzhanli($return['bangpai']);
	set_html('title','我的密室');
	exi($return);
}
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_jianghu_neili_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);	
	$basic=$return['pluginset'];
	foreach($return['list'] as &$v){
			$v['createtime']=date('Y-m-d H:m:s',$v['createtime']);
			$v['member']=cfc('core')->member_show($v['mid']);
	}
	exi($return);
}
if($_RQ['op']=='post'){
	$member=pdo_get('jy_jianghu_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$post=get_postdata();
	$fee=intval($post['fee']);
	if(!$fee){
		exi('请输入兑换内力！','erroe');
	}
	if($member['neili']<$fee){
		exi('兑换内力不能大于，当前内力！','erroe');
	}
	$return['pluginset']['creditrate']=$return['pluginset']['creditrate']?:10;
	$fee=intval($fee/$return['pluginset']['creditrate']);
	$this->model('member')->recharge($_SESSION['uid'],$fee,0,'内力兑换');
	model('core/member')->add_credit1($_SESSION['uid'],$fee,'内力的兑换');
	exi('兑换成功！');
}
